<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>泳道属性编辑</title>

		<link rel="stylesheet" href="../plugings/layui/css/layui.css" />

	</head>

	<body>
		<div style="width: 90%; margin: 0 auto;">
			<form class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">泳道名称：</label>
					<div class="layui-input-block">
						<input id="textId" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入文本信息" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<div class="layui-input-block">
						<button id="confirmId" class="layui-btn">确认</button>
						<button id="cancerId" class="layui-btn">取消</button>
						<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>
			</form>
		</div>
	</body>

	<script type="text/javascript" src="../js/component/jquery-1.11.0.min.js"></script>
	<script type="text/javascript" src="../plugings/layui/layui.all.js"></script>
	<script type="text/javascript" src="../js/main/util/zfsn-util-layui.js"></script>
	
	<script>
		let _base = parent.FLOW._base;
		let eleId;
		let laneObj;
		$(function() {
			eleId = parent.layuiUtil.tempId;
			let laneId = parent.$(eleId).parent().attr('id');
			laneObj = _base.laneObjs[laneId];
			$('#textId').val(laneObj.text);
		});
		
		$("#confirmId").click(function() {
			let v = $('#textId').val().trim();
			
			// 当去掉前后空格后的值不为图对象中的值时，说明值有改动，此时才更新图对象以及节点UI的展示
			if (v != laneObj.text) {
				// 更新泳道对象
				laneObj.text = $('#textId').val();
				
				// 更新节点
				if (laneObj.nodeType == 'broadwiseLane') {
					let tempText = '', textArr = v.split('');
					for (i = 0; i < textArr.length; i++) {
						tempText += '<span style="display: block;">' + textArr[i] + '</span>';
					}
					parent.$(eleId).html(tempText);
					parent.$(eleId).css('line-height', parent.ZFSN.getLaneLineHeight(v, parent.$(eleId).css('height')));
				} else {
					parent.$(eleId).html('<span>' + v+ '</span>');
				}
			}
			
			
			// 关闭弹窗
			layuiUtil.closeFrame();
		});
		
		// 点击取消
		$('#cancerId').click(function() {
			// 关闭弹窗
			layuiUtil.closeFrame();
		});
	</script>
	
</html>